import React, { Component } from 'react'
import './App.scss'
import { Redirect, Switch, Route } from 'react-router-dom'
import { appRoutes } from './routes'
import { isLogined } from './utils/auth';
import Frame from './components/Frame'

export default class App extends Component {
  render() {
    return (
      <div className="app">
        {
          isLogined()
            ?
            <Frame>
              <Switch>
                {
                  appRoutes.map(route => {
                    return <Route key={route.path} {...route} />
                  })
                }
                <Redirect to="/404" />
              </Switch>
            </Frame>
            :
            <Redirect to="/login" />
        }
      </div>
    )
  }
}
